#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H

#include <QObject>
#include <QVector2D>
#include <Narration/narrationnode.h>
#include <QFont>
#include "Render/renderwidget.h"
#include "Sound/soundmanager.h"
#include "eventcenter.h"
#include "GameUI/recorditem.h"
class GameManager:public QObject
{
    Q_OBJECT
public:
    //关键变量，决定程序是编辑器还是游戏
    bool isGame = false;
    GameManager(const GameManager&) = delete;
    GameManager& operator=(const GameManager&) = delete;
    static GameManager& Instance();
    ~GameManager();
    //game data
    QString name = "我的作品";
    QSize size = QSize(1200.0f,800.0f);
    NarrationNode* root = nullptr;
    QFont font = QFont("宋体",15);
    QString iconPath = "";

    //other
    NarrationNode* curNode = nullptr;
    RenderWidget* render = nullptr;

    int soundVolume = 50;
    int bgmVolume = 50;
    int bgseVolume = 50;
    //封面显示时播放的音乐
    QString bgmPath = "";
    bool fullScreen = true;

    void RunNarration(NarrationNode* root);
    void Stop();
    void ShowNarration(NarrationNode* root);
    void InitSounds(NarrationNode* root);
    void InitNode();
    void SetRecord(RecordItem* item);
    void Save();
    void Read();
private:
    GameManager();
    void Init();
    void HandleNarrartionOption(NarrationNode* node);
    void NextDialog(bool noBranch);
    //record
    RecordItem* record = nullptr;
    //设定好的可以加入图鉴的图片们
    QVector<QString> allAlbum;
    //读出硬盘中的allAlbum
    void ReadAlbum();
    //运行节点时判断有没有哪张是可以加入图鉴的
    void CheckAlbum(NarrationNode* node);
    void RunRecordFirstNode();
public slots:
    void RunNarrationNode(int id);
};

#endif // GAMEMANAGER_H
